#!/bin/sh

llvm_dir=$1
clang_version=$2
target=include/env/impl.hpp

# Create directories if they don't exist
mkdir -p include/env/

# Remove the impl.hpp to create a fresh one, since the PWD changes.
[ -f "$target" ] && rm -f "$target"
cat <<EOF > "$target"
/* XXX: Automagically generated. No touching. */
#pragma once

namespace color_coded
{
  template <>
  struct environment<env::tag>
  {
    static char constexpr const * const pwd{ "$PWD" };
    static char constexpr const * const clang_include
    { "-isystem${llvm_dir}/include" };
    static char constexpr const * const clang_include_cpp
    { "-isystem${llvm_dir}/include/c++/v1" };
    static char constexpr const * const clang_include_lib
    { "-isystem${llvm_dir}/lib/clang/${clang_version}/include" };
    static char constexpr const * const clang_resource_dir
    { "-resource-dir=${llvm_dir}/lib/clang/${clang_version}" };
  };
}
EOF
